home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / AmiVoGL_MDEV.lha / src / attr.c < prev    next >
C/C++ Source or Header  |  1994-04-12  |  3KB  |  132 lines

  1. #include <stdio.h>
  2. #include "vogl.h"
  3.  
  4. /* ---------------------------------------------------------------------
  5.  * Prototypes:
  6.  */
  7. #ifdef __PROTOTYPE__
  8. static void copyattributes( Attribute *,               /* attr.c          */
  9.    Attribute *);
  10. #else
  11. static void copyattributes();                          /* attr.c          */
  12. #endif
  13.  
  14. /* ---------------------------------------------------------------------
  15.  * Local Variables:
  16.  */
  17. static    Astack    *asfree =  (Astack *) NULL;
  18.  
  19. /* --------------------------------------------------------------------- */
  20.  
  21. /*
  22.  * copyattributes
  23.  *
  24.  *  Copies attribute stack entries from b to a
  25.  */
  26. static void copyattributes(
  27.   Attribute *a,
  28.   Attribute *b)
  29. {
  30. a->color = b->color;
  31. a->fontwidth = b->fontwidth;
  32. a->fontheight = b->fontheight;
  33. a->fontnum = b->fontnum;
  34. }
  35.  
  36. /* ------------------------------------------------------------------------ */
  37.  
  38. /*
  39.  * pushattributes
  40.  *
  41.  * save the current attributes on the matrix stack
  42.  *
  43.  */
  44. void pushattributes(void)
  45. {
  46. Astack    *nattr;
  47. Token    *p;
  48.  
  49. if (!vdevice.initialised)
  50. verror("pushattributes:  vogl not initialised");
  51.  
  52. if (vdevice.inobject) {
  53.     p = newtokens(1);
  54.  
  55.     p[0].i = PUSHATTRIBUTES;
  56.  
  57.     return;
  58.     }
  59.  
  60. if (asfree != (Astack *)NULL) {
  61.     nattr = vdevice.attr;
  62.     vdevice.attr = asfree;
  63.     asfree = asfree->back;
  64.     vdevice.attr->back = nattr;
  65.     copyattributes(&vdevice.attr->a, &nattr->a);
  66.     }
  67. else {
  68.     nattr = (Astack *)vallocate(sizeof(Astack));
  69.     nattr->back = vdevice.attr;
  70.     copyattributes(&nattr->a, &vdevice.attr->a);
  71.     vdevice.attr = nattr;
  72.     }
  73. }
  74.  
  75. /* ------------------------------------------------------------------------ */
  76.  
  77. /*
  78.  * popattributes
  79.  *
  80.  * pop the top entry on the attribute stack 
  81.  *
  82.  */
  83. void popattributes(void)
  84. {
  85. Astack    *nattr;
  86. Token    *p;
  87.  
  88. if (!vdevice.initialised)
  89. verror("popattributes: vogl not initialised");
  90.  
  91. if (vdevice.inobject) {
  92.     p = newtokens(1);
  93.  
  94.     p[0].i = POPATTRIBUTES;
  95.  
  96.     return;
  97.     }
  98.  
  99. if (vdevice.attr->back == (Astack *)NULL) 
  100. verror("popattributes: attribute stack is empty");
  101. else {
  102.     font((short) vdevice.attr->back->a.fontnum);
  103.     nattr = vdevice.attr;
  104.     vdevice.attr = vdevice.attr->back;
  105.     nattr->back = asfree;
  106.     asfree = nattr;
  107.     }
  108.  
  109. color(vdevice.attr->a.color);
  110. }
  111.  
  112. /* ------------------------------------------------------------------------ */
  113.  
  114. #ifdef    DEBUG
  115.  
  116. int printattribs(char *s)
  117. {
  118. printf("%s\n", s);
  119. printf("clipoff    = %d\n", vdevice.clipoff);
  120. printf("color      = %d\n", vdevice.attr->a.color);
  121. printf("textcos    = %f\n", vdevice.attr->a.textcos);
  122. printf("textsin    = %f\n", vdevice.attr->a.textsin);
  123. printf("fontwidth  = %f\n", vdevice.attr->a.fontwidth);
  124. printf("fontwidth  = %f\n", vdevice.attr->a.fontheight);
  125. printf("fontnum    = %d\n", vdevice.attr->a.fontnum);
  126. printf("mode       = %d\n", vdevice.attr->a.mode);
  127. }
  128.  
  129. /* ------------------------------------------------------------------------ */
  130.  
  131. #endif
  132.